
             
/**
 * 
 *
 * Copyright (c) 2012-2013 JLLT Corp. 2012-2013,All Rights Reserved.
 * This software is published under the 金麟龙腾商贸有限公司.
 * License version 1.0, a copy of which has been included with this
 * distribution in the LICENSE.txt file. 
 *
 * @File name:  QueryTCategoryByFCategoryIDAction.java   查询【类目信息:T_CATEGORY】
 * @Create on:  2012-07-10 22:23:111
 * @Author      :  高宇舟
 *
 * @ChangeList
 * ---------------------------------------------------
 * Date         Editor              ChangeReasons
 *
 */
           
package com.boho.ecp.base.action;

            
import java.sql.Connection;
import java.util.List;

import cn.boho.framework.actions.ActionImp;
import cn.boho.framework.context.ActionContext;
import cn.boho.framework.po.DynaBeanMap;
import cn.boho.framework.service.MessageService;

import com.boho.ecp.base.cache.TCategoryBrandCache;
import com.boho.ecp.base.cache.TCategoryCache;
import com.boho.ecp.constant.Product;
import com.boho.ecp.po.TBrandPO;
import com.boho.ecp.po.TCategoryPO;
public class QueryTCategoryByFCategoryIDAction extends ActionImp {
	private Connection con=null;
	@Override
	protected void doException(ActionContext atx, Exception ex) {
		atx.setErrorContext("EC_COMMON_1004", MessageService.getMessage("EC_COMMON_1004"),"【类目信息:T_CATEGORY|】" ,ex);
	}
	@Override
	protected int performExecute(ActionContext atx) throws Exception {
		Integer fCategoryId = atx.getIntegerValue("F_CATEGORY_ID");
		List list = TCategoryCache.queryTCategoryByFCategoryID(con,fCategoryId,1);
//		List list = TCategoryDao.queryTCategoryByFCategoryID(con,fCategoryId,1);
		for (int i=0, j=list.size(); i<j; i++) {
			DynaBeanMap dbm = (DynaBeanMap) list.get(i);
			int categoryId = Integer.parseInt(dbm.get("CATEGORY_ID")+"");
			List<TCategoryPO> childList = TCategoryCache.queryTCategoryForTreeMode(con, categoryId, 3);
//			List<TCategoryPO> childList = TCategoryDao.queryTCategoryForTreeMode(con, categoryId, 3);
			dbm.put("CATEGORY_CHILDS", childList);
			if (Integer.parseInt(dbm.get("F_CATEGORY_ID")+"") == Product.CATEGORY_MC_ROOT) {
				List<TBrandPO> brandList = TCategoryBrandCache.queryTCategoryBrandByCategoryID(con, categoryId);
//				List<TBrandPO> brandList = TCategoryBrandDao.queryTCategoryBrandByCategoryID(con,categoryId);
				dbm.put("BRAND_LIST", brandList);
			}
			list.set(i, dbm);
		}
		
		atx.setValue("T_CATEGORY", list.toArray());
		return 1;
	}
	@Override
	protected int verifyParameters(ActionContext atx) throws Exception {
		con = atx.getConection();
		return 1;
	}
}
